//
//  HttpUtil.h
//  Mahjong
//
//  Created by 饶首建 on 17/5/22.
//  Copyright © 2017年 com.ikamobile.com. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum : NSUInteger {
    GET = 0,
    POST = 1,
    PUT = 2,
    DELETE = 3,
} HttpMethod;

typedef void(^ResponseSuccess)(id response);
typedef void(^ResponseFail)(NSString *errorStr);

typedef void (^CompletioBlock)(NSDictionary *dic, NSURLResponse *response, NSError *error);
typedef void (^SuccessBlock)(NSDictionary *data);
typedef void (^FailureBlock)(NSError *error);

@interface HttpUtil : NSObject

+(UIViewController *)getCurrentVC;

+ (void)sendRequestURL:(NSString*)url method:(HttpMethod)httpMethod param:(NSDictionary *)param success:(ResponseSuccess)success fail:(ResponseFail)fail;
/**
 *  get请求
 */
+ (void)getWithUrlString:(NSString *)url parameters:(id)parameters success:(SuccessBlock)successBlock failure:(FailureBlock)failureBlock;

/**
 * post请求
 */
+ (void)postWithUrlString:(NSString *)url parameters:(id)parameters success:(SuccessBlock)successBlock failure:(FailureBlock)failureBlock;


@end
